package com.charlotte.study.gupao.strategy.draw;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author junjie.ding
 * @date 2020/3/16
 */
public class DrawStrategyFactory {

    private static final Map<String, IDrawStrategy> DRAW_STRATEGY_MAP = new ConcurrentHashMap<>(3);

    private static final String FIRST_PRIZE = "FIRST_PRIZE";

    private static final String SECOND_PRIZE = "SECOND_PRIZE";

    private static final String DEFAULT = "SECOND_PRIZE";

    static {
        DRAW_STRATEGY_MAP.put(FIRST_PRIZE, new FirstPriceStrategy());
        DRAW_STRATEGY_MAP.put(SECOND_PRIZE, new SecondPrizeStrategy());
        DRAW_STRATEGY_MAP.put(DEFAULT, new SecondPrizeStrategy());
    }

    public static IDrawStrategy getStrategy(String strategyName){
        if(DRAW_STRATEGY_MAP.containsKey(strategyName)){
            return DRAW_STRATEGY_MAP.get(strategyName);
        }
        return DRAW_STRATEGY_MAP.get(DEFAULT);
    }



}
